/*
	ncAppleTalk.h -- XPP AppleTalk Manager

	C Interface to the Macintosh Libraries
	Copyright Apple Computer,Inc. 1987
	All rights reserved.
*/

#ifndef __NAPPLETALK__
#define __NAPPLETALK__
#ifndef __TYPES__
#include <Types.h>
#endif
#ifndef __APPLETALK__
#include <AppleTalk.h>
#endif

				/* AFPCall command codes */

#define AFPByteRangeLock	1
#define AFPVolClose			2
#define AFPDirClose			3
#define AFPForkClose		4
#define AFPCopyFile			5
#define AFPDirCreate		6
#define AFPFileCreate		7
#define AFPDelete			8
#define AFPEnumerate		9
#define AFPFlush			10
#define AFPForkFlush		11
#define AFPGetDirParms		12
#define AFPGetFileParms		13
#define AFPGetForkParms		14
#define AFPGetSInfo			15
#define AFPGetSParms		16
#define AFPGetVolParms		17
#define AFPLogin			18
#define AFPContLogin		19
#define AFPLogout			20
#define AFPMapID			21
#define AFPMapName			22
#define AFPMove				23
#define AFPOpenVol			24
#define AFPOpenDir			25
#define AFPOpenFork			26
#define AFPRead				27
#define AFPRename			28
#define AFPSetDirParms		29
#define AFPSetFileParms		30
#define AFPSetForkParms		31
#define AFPSetVolParms		32
#define AFPWrite			33
#define AFPGetFlDrParms		34
#define AFPSetFlDrParms		35

#define AFPDTOpen			48
#define AFPDTClose			49
#define AFPGetIcon			51
#define AFPGtIcnInfo		52
#define AFPAddAPPL			53
#define AFPRmvAPPL			54
#define AFPGetAPPL			55
#define AFPAddCmt			56
#define AFPRmvCmt			57
#define AFPGetCmt			58

#define AFPAddIcon			192		/* Special code for ASP Write commands */

				/* ASP miscellaneous */

#define XPPLoadedBit		5				/* XPP bit in PortBUse */
#define XPPUnitNum			40				/* Unit number for XPP (old ROMs) */

#define SCBMemSize			0xC0 			/* Size of memory for SCB */

#define XPPFlagClr			0x00			/* constants for AFPCommandBlock */
#define XPPFlagSet			0x80			/* StartEndFlag & NewLineFlag fields. */



typedef struct AFPCommandBlock {
	char		CmdByte;
	char		StartEndFlag;
	short		ForkRefNum;
	long		RWOffset;
	long		ReqCount;
	char		NewLineFlag;
	char		NewLineChar;
} AFPCommandBlock;


#define XPPPBHeader \
	struct QElem	*qLink;			/* next queue entry */ \
	short			qType; 			/* queue type */ \
	short			ioTrap;			/* routine trap */ \
	Ptr				ioCmdAddr;		/* routine address */ \
	ProcPtr			ioCompletion;	/* completion routine */ \
	OSErr			ioResult;		/* result code */ \
	long			CmdResult;		/* Command result (ATP user bytes) */ \
	short			ioVRefNum;		/* volume reference or drive number */ \
	short			ioRefNum;		/* driver reference number ) */ \
	short			csCode			/* Call command code */

typedef struct XPPPrmBlk {
	XPPPBHeader;			
	short		SessRefnum;		/* Offset to session refnum */
	char		ASPTimeout;		/* Timeout for ATP */
	char		ASPRetry;		/* Retry count for ATP */
	short		CBSize;			/* Command block size */
	Ptr			CBPtr;			/* Command block pointer */
	short		RBSize;			/* Reply buffer size */
	Ptr			RBPtr;			/* Reply buffer pointer */
	short		WDSize;			/* Write data size */
	Ptr			WDPtr;			/* Write data pointer */
	char		CCBStart[296];	/* CCB memory allocated for driver */
				/*AFPWrite max size(CCB) = 296; all other calls = 150*/
} XPPPrmBlk;
	
typedef struct AFPLoginPrm {
	XPPPBHeader;			
	short		SessRefnum;		/* Offset to session refnum */
	char		ASPTimeout;		/* Timeout for ATP */
	char		ASPRetry;		/* Retry count for ATP */
	short		CBSize;			/* Command block size */
	Ptr			CBPtr;			/* Command block pointer */
	short		RBSize;			/* Reply buffer size */
	Ptr			RBPtr;			/* Reply buffer pointer */
	AddrBlock	AFPAddrBlock;	/* Address block in AFP login */
	Ptr			AFPSCBPtr;		/* SCB pointer in AFP login */
	Ptr			AFPAttnRoutine;	/* Attn routine pointer in AFP login */
	char		CCBfill[150-6];	/* CCB memory allocated for driver */
				/* Login needs only 150 bytes, BUT CCB really starts in the
					middle of AFPSCBPtr and also clobbers AFPAttnRoutine. */
} AFPLoginPrm;
	
typedef struct ASPOpenPrm {
	XPPPBHeader;			
	short		SessRefnum;		/* Offset to session refnum */
	char		ASPTimeout;		/* Timeout for ATP */
	char		ASPRetry;		/* Retry count for ATP */
	AddrBlock	ServerAddr;		/* Server address block */
	Ptr			SCBPointer;		/* SCB pointer */
	Ptr			AttnRoutine;	/* Attention routine pointer */
} ASPOpenPrm, *ASPOpenPrmPtr;

typedef struct ASPAbortPrm {
	XPPPBHeader;			
	Ptr			AbortSCBPtr;	/* SCB pointer for AbortOS */
} ASPAbortPrm;

typedef struct 
{
	XPPPBHeader;			
	short		ASPMaxCmdSize;	/* For SPGetParms */
	short		ASPQuantumSize;
	short		NumSesss;
} ASPGetparmsBlk;
	
typedef union XPPParamBlock {
	XPPPrmBlk xppPrmBlk;
	ASPGetparmsBlk aspGetParmsBlk;
	ASPAbortPrm aspAbortPrm;
	ASPOpenPrm aspOpenPrm;
	AFPLoginPrm afpLoginPrm;
} XPPParamBlock, *XPPParmBlkPtr;


pascal OSErr OpenXPP(XPPRefnum)
	short *XPPRefnum;
	extern;

pascal OSErr ASPOpenSession(xParamBlock, async)
	ASPOpenPrmPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPCloseSession(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPAbortOS(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPGetParms(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPCloseAll(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPUserWrite(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPUserCommand(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr ASPGetStatus(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;

pascal OSErr AFPCommand(xParamBlock, async)
	XPPParmBlkPtr xParamBlock;
	Boolean async;
	extern;


#endif
